package com.wty.cmims.controller;

import com.wty.cmims.pojo.ResponseResult;
import com.wty.cmims.service.HealthInstitutionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/healthInstitution")
@Tag(name = "医疗机构信息", description = "社区医疗信息后台管理系统api接口")
public class HealthInstitutionController {
    @Autowired
    private HealthInstitutionService healthInstitutionService;

    // 医疗机构信息获取
    @PostMapping("/find")
    @Operation(summary = "医疗机构信息获取", description = "医疗机构信息获取")
    @Parameter(name = "paramsMap",description = "参数列表")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<Map<String, Object>> healthInstitutionFind(@RequestBody Map<String,Object> paramsMap){
        return healthInstitutionService.healthInstitutionFind(paramsMap);
    }

    // 医疗机构信息修改
    @PutMapping("/update")
    @Operation(summary = "医疗机构信息修改", description = "医疗机构信息修改")
    @Parameter(name = "paramsMap",description = "参数列表")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<Void> healthInstitutionUpdate(@RequestBody Map<String,Object> paramsMap){
        return healthInstitutionService.healthInstitutionUpdate(paramsMap);
    }

    // 添加医疗机构
    @PostMapping("/add")
    @Operation(summary = "添加医疗机构", description = "添加医疗机构")
    @Parameter(name = "paramsMap",description = "参数列表")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<Void> healthInstitutionAdd(@RequestBody Map<String,Object> paramsMap){
        return healthInstitutionService.healthInstitutionAdd(paramsMap);
    }

    // 删除医疗机构
    @PutMapping("/delete")
    @Operation(summary = "删除医疗机构", description = "删除医疗机构")
    @Parameter(name = "id",description = "医疗机构ID")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<Void> deleteHealthInstitution(@RequestParam(name = "id") Integer institutionId){
        return healthInstitutionService.healthInstitutionDelete(institutionId);
    }

    // 医疗机构下拉框获取
    @PostMapping("/findHealthInstitutionDropDown")
    @Operation(summary = "医疗机构下拉框获取", description = "医疗机构下拉框获取")
    @Parameter(name = "paramsMap",description = "参数列表")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<Map<String, Object>> healthInstitutionDropDown(@RequestBody Map<String,Object> paramsMap){
        return healthInstitutionService.healthInstitutionDropDown(paramsMap);
    }
}